package org.vacoor.nothing.misc.express.usps.api.track;

import com.google.common.collect.Lists;
import org.vacoor.nothing.misc.express.usps.api.UspsRequest;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;

/**
 * USPS 追踪请求
 *
 * @author vacoor
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "TrackRequest")
public class TrackRequest extends UspsRequest {
    @XmlElement(name = "TrackID")
    private List<TrackId> trackIds;

    /* ********************
     *      Factory
     * ********************/

    public static TrackRequest of(String... ids) {
        List<TrackId> trackIds = Lists.newArrayList();
        for (String id : ids) {
            trackIds.add(new TrackId(id));
        }

        TrackRequest req = new TrackRequest();
        req.trackIds = trackIds;
        return req;
    }

    /* ************************
     *       Constructor
     * ************************/

    private TrackRequest() {
        super(null);
    }

    /* ***********************
     *         Methods
     * ***********************/

    public List<TrackId> getTrackIds() {
        return trackIds;
    }

    public void setTrackIds(List<TrackId> trackIds) {
        this.trackIds = trackIds;
    }
}
